<?php
class GalleriesFForm extends BaseFormAdmin{
	public function configure(){
		$langs = SysLanguages::getAllLang();
		foreach($langs as $lang){
			$this->setWidget('name_'.$lang, new sfWidgetFormInputText(array(), array('class' => 'required hz-required')));
			$this->setValidator('name_'.$lang, new sfValidatorString(array('max_length' => 255, 'required' => false)));
			
			$this->setWidget('description_'.$lang, new sfWidgetFormTextarea());
			$this->setValidator('description_'.$lang, new sfValidatorString(array('required' => false)));
			
		
		}
		$album_id_query = Doctrine_Query::create()
								->from('GalleryAlbums al')
								->leftJoin('al.GalleryAlbumsI18n lang')
								->select('al.id, lang.name as name')
								->where('al.is_enabled = 1 AND al.is_deleted = 0')
								->andWhere('(al.updated_at IS NULL OR al.updated_at >= al.created_at)')
								->andWhere('lang.lang = ?', sfContext::getInstance()->getUser()->getCulture())
								->orderBy('lang.name asc');
		
		$this->setWidget('gallery_album_id',new sfWidgetFormDoctrineChoice(array(
						'model' 		=> 'GalleryAlbums',
						'query'			=> $album_id_query,
						'multiple' 		=> false,
						'add_empty' 	=> __('select-option-all')), array('class' =>'required hz-required')
		));
		$this->setValidator('gallery_album_id', new sfValidatorDoctrineChoice(array(
				'model' => 'GalleryAlbums', 
				'query' => $album_id_query,
				'required' => true), array('required'=> 'error-select')
		));
		
		$this->setWidget('photo_url', new sfWidgetFormInputHidden(array(), array('class' => 'required hz-img-required  upload-photo')));
		$this->setValidator('photo_url', new sfValidatorString(array('required' => false)));
		
		parent::configure();
	}
}
